package ran.judge.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ran.api.domain.dto.JudgeSubmitDTO;
import ran.constants.RabbitMQConstants;
import ran.judge.service.IJudgeService;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-11-24
 * Time: 20:31
 */
@Component
@Slf4j
public class JudgeConsumer {
    @Autowired
    private IJudgeService judgeService;
    @RabbitListener(queues = RabbitMQConstants.OJ_WORK_QUEUE) // 监听队列, 监听到消息之后进行消费
    public void consume(JudgeSubmitDTO judgeSubmitDTO) {
        log.info("收到消息为: {}", judgeSubmitDTO);
        judgeService.doJudgeJavaCode(judgeSubmitDTO);
    }

}
